﻿@model ORM.Business.Models.Entities.GuideComment

@{
    ViewBag.Title = "Sửa Bình Luận";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/ckeditor/ckeditor.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/ckeditor/adapters/jquery.js")"></script>

<table class="contentBox" width="100%">
  <tr>
                    <th class="boxTitle">Sửa Bình Luận<span id="guidecommentNavigator"></span></th>
                </tr>
<tr>
<td style="vertical-align: top">



@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.GuideId)
        <div class="editor-field">
            @Html.TextAreaFor(model => model.ContentHtml, new { @id = "ckeditor" })
            @Html.ValidationMessageFor(model => model.ContentHtml)
        </div>
             <br/><br/>
            <div style="float: right">
               <table>
                <tr>
                    <td><input type="submit" id = "btnSubmitComment" value="Lưu Lại" style="width: 120px; height: 27px;"/></td>
                    <td><input type="button" id="btnCancelComment" value="Huỷ" style="width: 100px; height: 25px; font-size: 13px"/></td>
                </tr>
            </table> 
            </div>
    
    @*<p>
            <input type="submit" value="Save" />
        </p>*@
    
}
</td>
    </tr>
    </table>

<script type="text/javascript">
    CKEDITOR.replace('ckeditor',
    {
    filebrowserImageBrowseUrl: '/Scripts/ckfinder/ckfinder.html?type=Images',
    filebrowserImageUploadUrl: '/Scripts/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images',
    });

     $('#btnSubmitComment').click(function() {
            for (var instanceName in CKEDITOR.instances) {
            var string = CKEDITOR.instances[instanceName].getData();
            string = string.replace(/<\/?[^>]+(>|$)/g, "");
            string = string.replace(/[&]nbsp[;]/gi," ");
            if(string.trim() != "") {
                CKEDITOR.instances[instanceName].updateElement();
            }            
        }
        });
         $('#btnCancelComment').click(function() {
           $(document.createElement('div'))
        .attr({title: 'Fixtech.vn', 'class': 'alert'})
        .html("Bạn có chắc muốn huỷ thông tin đã sửa?")
        .dialog({
            buttons: {"Xác Nhận": function() {
                window.location.href = "/Guide/Details/"+@Model.Id;
                $(this).dialog('close');
            }, "Quay Lại": function(){$(this).dialog('close');}},
            close: function(){$(this).remove();},
            draggable: true,
            modal: true,
            resizable: false,
            width: 500,
            open: function(event, ui) {
        $("button").blur();
    }
});
        });
    </script>


